package com.xintoucloud.pbs.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.xintoucloud.pbs.dao.PartyMemberPermissionMenuDao;
import com.xintoucloud.pbs.entity.PartyMemberPermissionMenu;
@Repository@Transactional
public class PartyMemberPermissionMenuDaoImpl implements PartyMemberPermissionMenuDao{
	@Autowired
	private SessionFactory sessionFactory;
	@Override
	public List<PartyMemberPermissionMenu> listByPartyMemberPermissionppid(int ppid) {
		return sessionFactory.getCurrentSession().createQuery("from PartyMemberPermissionMenu where PartyMemberPermission_ppid=?0").setParameter(0, ppid).getResultList();
	}
	@Override
	public void updateState(int ppid, int pmid, int state) {
		sessionFactory.getCurrentSession().createQuery("update PartyMemberPermissionMenu set state='"+state+"' where PartyMemberPermission_ppid='"+ppid+"' and Menu_pmid='"+pmid+"' ").executeUpdate();
	}
	@Override
	public PartyMemberPermissionMenu getState(int ppid, int pmid) {
		return (PartyMemberPermissionMenu) sessionFactory.getCurrentSession().createQuery("from PartyMemberPermissionMenu where PartyMemberPermission_ppid='"+ppid+"' and Menu_pmid='"+pmid+"'").uniqueResult();
		
	}
	
}
